using System;
using System.Data;

using SqlHelperForCry.Common;

namespace Torch.WL.Entity
{
    [Table("Tb_Sys_AuthorityDir", "AuthorityID", "Torch.WL.ConnectionString")]
	public class Tb_Sys_AuthorityDir : Info
	{
		#region SQL column name consts 
		public const string SQLCOL_AUTHORITYID = "AuthorityID";
		public const string SQLCOL_AUTHORITYNAME = "AuthorityName";
		public const string SQLCOL_AUTHORITYTAG = "AuthorityTag";
		public const string SQLCOL_AUTHORITYDESCRIPTION = "AuthorityDescription";
		public const string SQLCOL_AUTHORITYORDER = "AuthorityOrder";
		public const string SQLCOL_TYPENAME = "TypeName";
		#endregion


		#region Contructors
		/// <summary>
		/// Construct empty entity
		/// </summary>
		public Tb_Sys_AuthorityDir () {}

		/// <summary>
		/// Construct entity by primary key, other fields will be assigned by 
		/// "Load" method.
		/// </summary>
		public Tb_Sys_AuthorityDir (int AuthorityID)
		{
			this.AuthorityID = AuthorityID;
		}
		#endregion

		public override void Init (DataRow row)
		{
			AuthorityID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_AUTHORITYID]);
			AuthorityName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_AUTHORITYNAME]);
			AuthorityTag = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_AUTHORITYTAG]);
			AuthorityDescription = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_AUTHORITYDESCRIPTION]);
			AuthorityOrder = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_AUTHORITYORDER]);
			TypeName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_TYPENAME]);
		}

		#region Properties 
		#region Property <int> AuthorityID
		[Property("AuthorityID", 4, SqlDbType.Int, true, true)]
		public int AuthorityID 
		{
			get { return _AuthorityID; }
			set { _AuthorityID = value; }
		}
		private int _AuthorityID = int.MinValue;
		#endregion

		#region Property <string> AuthorityName
		[Property("AuthorityName", 60, SqlDbType.NVarChar, false, false)]
		public string AuthorityName 
		{
			get { return _AuthorityName; }
			set { _AuthorityName = value; }
		}
		private string _AuthorityName = null;
		#endregion

		#region Property <string> AuthorityTag
		[Property("AuthorityTag", 100, SqlDbType.NVarChar, false, false)]
		public string AuthorityTag 
		{
			get { return _AuthorityTag; }
			set { _AuthorityTag = value; }
		}
		private string _AuthorityTag = null;
		#endregion

		#region Property <string> AuthorityDescription
		[Property("AuthorityDescription", 100, SqlDbType.NVarChar, false, false)]
		public string AuthorityDescription 
		{
			get { return _AuthorityDescription; }
			set { _AuthorityDescription = value; }
		}
		private string _AuthorityDescription = null;
		#endregion

		#region Property <int> AuthorityOrder
		[Property("AuthorityOrder", 4, SqlDbType.Int, false, false)]
		public int AuthorityOrder 
		{
			get { return _AuthorityOrder; }
			set { _AuthorityOrder = value; }
		}
		private int _AuthorityOrder = int.MinValue;
		#endregion

		#region Property <string> TypeName
		[Property("TypeName", 30, SqlDbType.VarChar, false, false)]
		public string TypeName 
		{
			get { return _TypeName; }
			set { _TypeName = value; }
		}
		private string _TypeName = null;
		#endregion
		#endregion


		public bool LoadByIdentity(int AuthorityID)
		{
			return DataAccess.SelectByIdentity(this, Convert.ToInt64(AuthorityID));
		}


		public bool DeleteByIdentity()
		{
			return DataAccess.DeleteByIdentity(this);
		}
	}
}
